<?php
namespace app\services;

 
class SystemServices extends BaseServices{


    protected $rpcServer = 'system';


    /**
     * 资料
     */
    public function getMeansByConf(){
        $cacheName = md5('getMeansByConf_'.json_encode($this->system));
        $list = \think\facade\Cache::get($cacheName);
        if(empty($list)){
            $data = $this->apiLink($this->rpcServer,'api/lottery/getMeansByConf',[]);
            if($data['code'] !== 200) {
                $this->error($data['message']);
            }
            $list = [
                'sig' => $data['sig'],
                'data' => $data['data']
            ];
            \think\facade\Cache::set($cacheName,$list,getCacheTime());
        }
        return $list;
    }

    //彩种分类列表
    public function getLotteryCategoryList(array $param=[]){
        $cacheName = md5('getLotteryCategoryList_'.json_encode($this->system));
        $list = \think\facade\Cache::get($cacheName);
        if(empty($list)){
            $data = $this->apiLink($this->rpcServer,'api/lottery/getLotteryList',$param);
            if($data['code'] !== 200) {
                $this->error($data['message']);
            }
            $list = [
                'sig' => $data['sig'],
                'data' => $data['data']
            ];
            \think\facade\Cache::set($cacheName,$list,getCacheTime());
        }
        
        return $list;
    }


    //彩种开奖列表
    public function getDrawprizeList(array $param=[]){
        $cacheName = md5('getDrawprizeList_'.json_encode($this->system).json_encode($param));
        $list = \think\facade\Cache::get($cacheName);
        if(empty($list)){
            $data = $this->apiLink($this->rpcServer,'api/lottery/getDrawprizeList',$param);
            if($data['code'] !== 200) {
                $this->error($data['message']);
            }
            $list = [
                'sig' => $data['sig'],
                'data' => $data['data']
            ];
            \think\facade\Cache::set($cacheName,$list,getCacheTime());
        }
        
        return $list;
    }

    //查询最新开奖
    public function getDrawprizeInfo(array $param=[]){
        $data = $this->apiLink($this->rpcServer,'api/lottery/getDrawprizeInfo',$param);
        if($data['code'] !== 200) {
            $this->error($data['message']);
        }
        $list = [
            'sig' => $data['sig'],
            'data' => $data['data']
        ];
        return $list;
    }



    //1258导航
    public function getNavs(array $param=[]){
        $cacheName = md5('getNavs_'.json_encode($this->system));
        $list = \think\facade\Cache::get($cacheName);
        if(empty($list)){
            $data = $this->apiLink($this->rpcServer,'api/navs/getNavs',$param);
            if($data['code'] !== 200) {
                $this->error($data['message']);
            }
            $list = [
                'sig' => $data['sig'],
                'data' => $data['data']
            ];
            \think\facade\Cache::set($cacheName,$list,getCacheTime());
        }
        
        return $list;
    }
    

    public function flowStatistics(array $param=[]){
        $data = $this->apiLink($this->rpcServer,'api/flowStatistics',$param);
        if($data['code'] !== 200) {
            $this->error($data['message']);
        }

        return $data;
    }

    
}
